package good

import (
	"api/internal/respons"
	"api/internal/svc"
	"api/internal/types"
	"context"
	"homepage_srv/homepageclient"

	"github.com/zeromicro/go-zero/core/logx"
)

type GoodShopLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewGoodShopLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GoodShopLogic {
	return &GoodShopLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

// 商品店铺信息
func (l *GoodShopLogic) GoodShop(req *types.GoodShopRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line
	shop, err := l.svcCtx.HomepageGrpc.GoodShop(l.ctx, &homepageclient.GoodShopRequest{
		GoodId: req.GoodId,
	})
	if err != nil {
		return respons.Error(400, "服务端错误", err.Error()), err
	}
	return respons.Success(shop), nil
}
